/**
 * 用户相关的请求模块
 */
import request from '@/utils/request'

/**
  * 用户登录
  */
export function login (data) {
  return request({
    method: 'POST',
    url: '/users/login',
    data
  })
}

/**
 * 获取当前登录用户自己信息
 */
export function getUserInfo (userid) {
  return request({
    method: 'GET',
    url: `/users/getuserinfo/${userid}`
  })
}

// 更新头像
export function updateUserPhoto (userid, formData) {
  return request({
    method: 'PATCH',
    url: `/users/updateuserphoto/${userid}`,
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryn8D9asOnAnEU4Js0' }
  })
}

// 更新基本信息
export function updateUserProfile (userid, userInfo) {
  return request({
    method: 'PUT',
    url: `/users/updateuserinfo/${userid}`,
    data: userInfo
  })
}
// 获取用户视频
export function getUserSelfVideo (userid, videoType, page) {
  return request({
    method: 'GET',
    url: `/users/getuserselfvideo/${userid}?videoType=${videoType}&page=${page}`
  })
}

// 获取城市信息
export function getLocation () {
  return request({
    method: 'GET',
    url: '/location'
  })
}

// 更新用户的喜欢
export function updateUserLikeStyle (userid, data) {
  return request({
    method: 'PUT',
    url: `/users/updateuserlikestyle/${userid}`,
    data: data
  })
}

// 获取用户喜欢的视频
export function getUserLikeVideo (userid) {
  return request({
    method: 'GET',
    url: `/users/getuserlikevideo/${userid}`
  })
}

// 用户发布了一个视频
export function addUserVideo (userid, formData) {
  return request({
    method: 'POST',
    url: `/users/adduservideo/${userid}`,
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryn8D9asOnAnEU4Js0' }
  })
}

// 用户加入喜欢一个视频
export function addUserLikeVideo (userid, videoid) {
  return request({
    method: 'POST',
    url: `/users/adduserlikevideo/${userid}`,
    data: { videoid }
  })
}

// 用户取消喜欢一个视频
export function removeUserLikeVideo (userid, videoid) {
  return request({
    method: 'DELETE',
    url: `/users/removeuserlikevideo/${userid}`,
    data: { videoid }
  })
}

// 用户评论一个视频
export function createComment (userid, data) {
  return request({
    method: 'POST',
    url: `/users/createcomment/${userid}`,
    data: data
  })
}

// 用户删除一个视频
export function removeUserComment (userid, data) {
  return request({
    method: 'DELETE',
    url: `/users/removeuserComment/${userid}`,
    data: data
  })
}

// 用户
export function onLikeComment (userid, data) {
  return request({
    method: 'POST',
    url: `/users/onlikecomment/${userid}`,
    data: data
  })
}

// 用户取消喜欢一个评论
export function removeuserlikecomment (userid, data) {
  return request({
    method: 'POST',
    url: `/users/removeUserLikeComment/${userid}`,
    data: data
  })
}

// 获取用户粉丝列表
export function getuserfans (userid, page) {
  return request({
    method: 'GET',
    url: `/users/getuserfans/${userid}?page=${page}`
  })
}

// 获取用户粉丝列表
export function getuserfollow (userid, page) {
  return request({
    method: 'GET',
    url: `/users/getuserfollow/${userid}?page=${page}`
  })
}

// 注册用户
export function register (data) {
  return request({
    method: 'POST',
    url: '/users/regist',
    data
  })
}

// 关注用户
export function addUserFollow (userid, data) {
  return request({
    method: 'POST',
    url: `/users/adduserfollow/${userid}`,
    data
  })
}

// 取消关注
export function removeUserFollow (userid, data) {
  return request({
    method: 'DELETE',
    url: `/users/removeuserfollow/${userid}`,
    data
  })
}

// 获取推荐
export function getRecommentVideo () {
  return request({
    method: 'GET',
    url: '/users/getrecommentvideo'
  })
}

// 获取用户关注视频
export function getUserFocusVideo (page) {
  return request({
    method: 'GET',
    url: `/users/getuserfocusvideo?page=${page}`
  })
}

// 获取用户消息队列
export function getUserMessage (userid) {
  return request({
    method: 'GET',
    url: `/users/getusermessage/${userid}`
  })
}

// 获取用户消息队列
export function createMessage (userid, data) {
  return request({
    method: 'POST',
    url: `/users/createmessage/${userid}`,
    data
  })
}
// 获取消息详情队列
export function getOneMessage (userid, chatUserid) {
  return request({
    method: 'GET',
    url: `/users/getonemessage/${userid}?chatUserid=${chatUserid}`
  })
}
// 删除消息
export function removeUserMessage (userid, data) {
  return request({
    method: 'DELETE',
    url: `/users/removeusermessage/${userid}`,
    data
  })
}

export function removeUserSelfVideo (userid, data) {
  return request({
    method: 'DELETE',
    url: `/users/removeuserselfvideo/${userid}`,
    data
  })
}
